'''
Created on 30 avr. 2011

@author: shin
'''
import unittest
from business.GameStatus   import GameStatus
from business.DamierStatus import DamierStatus
from stub.Damier           import Damier
from stub.DaoDamier        import DaoDamier
from stub.DaoElement       import DaoElement
from stub.Personnage       import Personnage

class Test(unittest.TestCase):

    def setUp(self):
        self.gameStatus = GameStatus(Damier(DaoDamier))

    def tearDown(self):
        del self.gameStatus


    def test_init_tour(self):
        self.assertEqual(self.gameStatus.tour, "")

    def test_init_damier(self):
        self.assertEqual(isinstance(self.gameStatus.damier, DamierStatus),
                         True )

    def test_maj_tour(self):
        self.assertEqual(self.gameStatus.maj_tour(""), None)

    def test_maj_terrain(self):
        case = DaoElement("Terrain", "Herbe")
        self.assertEqual(self.gameStatus.maj_terrain(case), None)
        self.assertEqual(self.gameStatus.terrain,
                         "Herbe\n0\noui\n" )

    def test_maj_perso1(self):
        perso = Personnage(DaoElement("Guerrier", "Nain"))
        self.assertEqual(self.gameStatus.maj_perso(1, perso, None), None)
        self. assertEqual(self.gameStatus.persoChoix,
                          'Rankor\n'
                          '\n'
                          '0\n'
                          '0\n'
                          '0\n'
                          '0\n'
                          'non\n'
                          '0\n'
                          '0\n'
                          '0\n'
                          '0\n' )

    def test_maj_perso2(self):
        perso = Personnage(DaoElement("Guerrier", "Nain"))
        self.assertEqual(self.gameStatus.maj_perso(2, perso, None), None)
        self. assertEqual(self.gameStatus.persoCible,
                          'Rankor\n'
                          '\n'
                          '0\n'
                          '0\n'
                          '0\n'
                          '0\n'
                          'non\n'
                          '0\n'
                          '0\n'
                          '0\n'
                          '0\n' )

    def test_maj_action(self):
        personnage = DaoElement("Guerrier", "Nain")
        self.assertEqual(self.gameStatus.maj_action(personnage), None)
        self.assertEqual(self.gameStatus.action, ['Passe son tour',
                                                  'Frappe',
                                                  'Brise Genoux',
                                                  'Mouvement'])

    def test_maj_damier(self):
        self.assertEqual(self.gameStatus\
                                .maj_caseDamier("A1", "marque_selection"),
                         None )        


        
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()